<template>
  <div class="login-way-switcher" @click="switchLoginWay">
    <div class="switcher" :class="props.loginWay === 'qrcode' ? '' : 'active'">
      <div>密码登录</div>
    </div>
    <div v-if="showQrcode" class="switcher" :class="props.loginWay === 'qrcode' ? 'active' : ''">微信登录</div>
  </div>
</template>

<script lang="ts" setup>
import HomeQRCode from "@/assets/login/home_qrcode.png";
import { TLoginWay } from "@/views/passport/types/login";

const props = defineProps<{
  loginWay: TLoginWay
}>()

const emits = defineEmits(['update:login-way'])

const switchLoginWay = () => {
  if (props.loginWay === 'account_password') {
    emits('update:login-way', 'qrcode')
  } else {
    emits('update:login-way', 'account_password')
  }
}

const showQrcode = computed(() => {
  const route = useRoute()
  return route.meta.modeType !== 'input'
})
</script>

<style scoped lang="scss">
.login-way-switcher {
  height: 30px;
  line-height: 30px;
  font-family: AlibabaPuHuiTi-Medium, AlibabaPuHuiTi;
  font-weight: 500;
  color: #7F858B;
  display: flex;

  .switcher {
    height: 30px;
    line-height: 30px;
    margin-right: 20px;
    font-size: 18px;
    font-family: AlibabaPuHuiTi-Medium, AlibabaPuHuiTi;
    font-weight: 500;
    color: #7F858B;
    border-bottom: 1px solid transparent;
    min-width: 70px;
    text-align: center;
    cursor: pointer;

    &.active {
      color: #1964FA;
      border-bottom: 1px solid #1964FA;
    }
  }
}
</style>
